﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WeiXinWeb.Models;
using WeiXinWeb.Helper;
using WeiXinWeb.Server;

namespace WeiXinWeb.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult UpdatePasswordView(string pan)
        {
            TruckCompany TC = (TruckCompany)HelpCookies.CurrentUserObject;
            ViewBag.tc = TC;
            ViewBag.Isdefault = pan;
            return View(TC);
        }

        [HttpPost]
        public ActionResult UpdatePassword(string password)
        {
            var mode =(TruckCompany) HelpCookies.CurrentUserObject;
            mode.password = Helper.SimpleCrypt.Encode(password);
            var result =new TruckServer().UpdatePW(mode);
            var message = result ? "" : "数据操作失败，修改密码失败！";
            return Json(message);
        }

    }
}
